function deepCopy(obj1){
    var obj2 = Object.prototype.toString.call(obj1)==='[object Array]'?[]:{}
    for(var key in obj1){
        if(obj1.hasOwnProperty(key)){
            if(typeof obj1[key] === 'object'){
                obj2[key] = deepCopy(obj1[key])
            }else{
                obj2[key] = obj1[key]
            }
        }
    }
    return obj2
}
let obj1 = [1,42,4,56,2,2]
const obj2 = deepCopy(obj1)
console.log(obj2);